using System;
using TMPro;
using UnityEngine;

public class timeCount : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    bool isStartCount;
    public TMP_Text time;
    string currentTime;
    int startTime;
    void Start()
    {
        LevelManager.I.OnGameBegin+=StartCount;
    }
    void StartCount()
    {
        isStartCount=true;
        startTime=(int)Time.time;
    }
    string ConvertTime(int seconds)
    {
        int min=seconds/60;
        int second=seconds%60;
        return string.Format("{0:D2}:{1:D2}", min, seconds);
    }
    // Update is called once per frame
    void Update()
    {
        if(isStartCount)
        {
            currentTime = ConvertTime((int)Time.time-startTime);
            time.text=currentTime;
        }
    }
}
